package cn.iocoder.yudao.module.bpm.controller.admin.tohandle.center;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.bpm.api.tohandle.dto.*;

import cn.iocoder.yudao.module.bpm.controller.admin.tohandle.center.vo.BpmHandleTaskRespVO;
import cn.iocoder.yudao.module.bpm.service.tohandle.BpmHandleCenterService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 待办中心")
@RestController
@RequestMapping("/bpm/handle-center")
@Validated
public class BpmHandleCenterController {

    @Resource
    private BpmHandleCenterService bpmHandleCenterService;

    /**
     * 添加待办
     * */
    @PostMapping("/addToHandleFlowTask")
    @Operation(summary = "获取 Todo 待办任务分页")
    @PreAuthorize("@ss.hasPermission('bpm:handle-center:create')")
    public CommonResult<List<Long>> addToHandleFlowTask(@Valid @RequestBody List<BpmHandleFlowTaskCreateReqDTO> bpmHandleTaskRespDTOList) {
        return success(bpmHandleCenterService.addToHandleFlowTask(bpmHandleTaskRespDTOList));
    }

    /**
     * 查询待办任务列表
     *
     * @return 待办列表
     */
    @GetMapping("/getToHandleTaskList")
    @Operation(summary = "获取 Todo 待办任务分页")
    @PreAuthorize("@ss.hasPermission('bpm:handle-center:query')")
    public CommonResult<PageResult<BpmHandleTaskRespVO>> getToHandleTaskList(@Valid @RequestBody PageParam pageParam, @Valid @RequestBody BpmHandleTaskSearchReqDTO reqDTO) {
        return success(bpmHandleCenterService.getToHandleTaskList(pageParam, reqDTO));
    }

    /**
     * 分页查询待阅
     * */

    /**
     * 分页查询已办
     * */

    /**
     * 分页查询我发起的
     * */

    /**
     * 添加收藏
     */
    @GetMapping("/addCollect")
    @Operation(summary = "添加收藏")
    @PreAuthorize("@ss.hasPermission('bpm:add-center:create')")
    public CommonResult<List<Long>> addCollect(@Valid @RequestBody List<BpmCollectCreateReqDto> createCollectReqDtos) {
        return success(bpmHandleCenterService.addCollect(createCollectReqDtos));
    }


    /**
     * 分页查询我的收藏
     */
    @GetMapping("/searchCollect")
    @Operation(summary = "添加收藏")
    @PreAuthorize("@ss.hasPermission('bpm:search-center:query')")
    PageResult<BpmCollectInfoResDto> searchCollect(@Valid @RequestBody PageParam pageParam, BpmCollectSearchReqDto bpmCollectSearchReqDto) {
        return bpmHandleCenterService.searchCollect(pageParam, bpmCollectSearchReqDto);
    }


}
